<?php

namespace paper\bootstrap;

use paper\App;
use paper\Config;
use paper\constraint\Bootstrap;
use paper\dao\Connection;
use paper\dao\Db;

class DbSupportRegister implements Bootstrap
{

    function onBoot(App $app)
    {
        $app->singleton(Db::class, function () {
            $config = Config::load("database");
            $default = $config->get("default_type", "mysql");
            return new Db($config->get('connections.' . $default, []));
        });
    }
}